#include <iostream>
#include <algorithm>

using namespace std;

struct D
{
    D(int i = 0)
        :num(i)
    {}
    int num;
    void print() {cout << num << endl;};
};

struct print_D
{
    void operator() (const D* d) const
    {
        cout << d->num << endl;
    }
};

void test()
{
    vector<D*> vDptr; 
    vDptr.push_back(new D(1));
    vDptr.push_back(new D(2));

    for_each(vDptr.begin(), vDptr.end(), print_D());
    for_each(vDptr.begin(), vDptr.end(), mem_fun_ref(&D::print));
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}
